home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / biz / demo / StylusDemo.lha / Stylus_Demo / REXX / RoundRect.pvrx < prev    next >
Text File  |  1994-08-18  |  3KB  |  119 lines

  1. /* RoundRect.pvrx---draw rectangles with counfigurably rounded
  2.         corners.
  3.    Author:  Jeff Blume - March 25, 1992
  4.    Copyright © 1992 by Stylus, Inc.
  5.  
  6.    Suggested "ProVector.pvrx" entries:
  7.  
  8.     'Define "RoundRect  Ctrl-R" "RoundRect MENU"'
  9.     'DefineKey R "RoundRect MENU"'
  10. */
  11.  
  12.  
  13. /* Get the argument list to see whether this is a MENU, or an OK */
  14. arg Cmd
  15.  
  16. /* Try to get exclusive lock on project window.
  17.     If can't get lock, not polite to interrupt. */
  18. 'Lock'
  19. if RC ~= 0 then exit
  20.  
  21. options results
  22.  
  23. ErrTxt = ""
  24.  
  25. /* This loop is called from the menu */
  26. if Cmd = 'MENU' then 'GetUserData 2 2 2 "RoundRect OK" ""'
  27.  
  28. /* This was called from GetUserData */
  29. if Cmd = 'OK' then
  30. DO
  31.     'GetInputPoints InPts'
  32.     'PushUndo'
  33.  
  34.     'GetStr "Rounding Percentage? (RETURN = 20)" "OK" "CANCEL"'
  35.     Rnd = result
  36.     if rc ~= 0 then call Error "MACRO CANCELED"
  37.     if Rnd = "" then Rnd = 20
  38.  
  39.     /* Convert percent to decimal, so user doesn't have to */
  40.     Rnd = Rnd/100
  41.  
  42.     /* Initialize INDICATOR's */
  43.     Pts.0.X = "INDICATOR"
  44.     Pts.0.Y = 1
  45.     Pts.5.X = "INDICATOR"
  46.     Pts.5.Y = 1
  47.     Pts.10.X = "INDICATOR"
  48.     Pts.10.Y = 1
  49.     Pts.15.X = "INDICATOR"
  50.     Pts.15.Y = 1
  51.  
  52.     /* Calculate anchors and controls */
  53.  
  54.     /* Width (DX), height (DY) of rect, & shortest (RD) */
  55.     /* RD is Reference Dimension for corner offsets */
  56.     DX = InPts.1.X - InPts.0.X
  57.     DY = InPts.1.Y - InPts.0.Y
  58.     if abs(DX) <= abs(DY) then RD = DX
  59.     else RD = DY
  60.  
  61.     /* First corner - usually lower left corner */
  62.     Pts.1.X = InPts.0.X
  63.     Pts.1.Y = InPts.1.Y - (RD * Rnd / 2)
  64.     Pts.2.X = InPts.0.X
  65.     Pts.2.Y = InPts.1.Y - (RD * Rnd / 4)
  66.  
  67.     Pts.3.X = InPts.0.X + (RD * Rnd / 4)
  68.     Pts.3.Y = InPts.1.Y
  69.     Pts.4.X = InPts.0.X + (RD * Rnd / 2)
  70.     Pts.4.Y = InPts.1.Y
  71.  
  72.     /* Second corner - usually lower right corner */
  73.     Pts.6.X = InPts.1.X - (RD * Rnd / 2)
  74.     Pts.6.Y = InPts.1.Y
  75.     Pts.7.X = InPts.1.X - (RD * Rnd / 4)
  76.     Pts.7.Y = InPts.1.Y
  77.  
  78.     Pts.8.X = InPts.1.X
  79.     Pts.8.Y = InPts.1.Y - (RD * Rnd / 4)
  80.     Pts.9.X = InPts.1.X
  81.     Pts.9.Y = InPts.1.Y - (RD * Rnd / 2)
  82.  
  83.     /* Third corner - usually upper right corner */
  84.     Pts.11.X = InPts.1.X
  85.     Pts.11.Y = InPts.0.Y + (RD * Rnd / 2)
  86.     Pts.12.X = InPts.1.X
  87.     Pts.12.Y = InPts.0.Y + (RD * Rnd / 4)
  88.  
  89.     Pts.13.X = InPts.1.X - (RD * Rnd / 4)
  90.     Pts.13.Y = InPts.0.Y
  91.     Pts.14.X = InPts.1.X - (RD * Rnd / 2)
  92.     Pts.14.Y = InPts.0.Y
  93.  
  94.     /* Fourth corner - usually upper left corner */
  95.     Pts.16.X = InPts.0.X + (RD * Rnd / 2)
  96.     Pts.16.Y = InPts.0.Y
  97.     Pts.17.X = InPts.0.X + (RD * Rnd / 4)
  98.     Pts.17.Y = InPts.0.Y
  99.  
  100.     Pts.18.X = InPts.0.X
  101.     Pts.18.Y = InPts.0.Y + (RD * Rnd / 4)
  102.     Pts.19.X = InPts.0.X
  103.     Pts.19.Y = InPts.0.Y + (RD * Rnd / 2)
  104.  
  105.     /* Draw rounded rectangle */
  106.     'Polygon' 20 Pts; Obj = result
  107.     'SelectObj' Obj
  108. END
  109. /* end "OK" loop */
  110.  
  111. 'UnLock'
  112. EXIT
  113.  
  114. ERROR:
  115.     arg ErrTxt
  116.     if ErrTxt ~= "" then 'GetBool ErrTxt "Cancel" "Cancel"'
  117.     'UnLock'
  118.     exit
  119.